//creator James
//date 2012 03 14

var express=require("express");
var app=express.createServer();
var cradle=require('cradle');
var db= new(cradle.Connection)('127.0.0.1',5984,{
    cache:true,
    raw:false
}).database('em');
app.use(express.static("./stat"));
app.use(express.bodyParser());
app.set("views","./views");
app.set("view engine","jade");
app.get("/",function(req,res){
	res.render("reg");
});
app.get("/index",function(req,res){
	res.render("index");
});

app.post("/reg",function(req,res){
    res.end(req.body.name+" "+req.body.pwd);
    db.save({
        name:req.body.name,
        pwd:req.body.pwd
    },function(err,res){})
});

app.listen(8000,"127.0.0.1");